

	 

$(document).ready(function(){
	var month = $('.time_center').attr('data_time');
    Ajax('line',month)
	
	//点击全部产品   执行的动作  隐藏”今日销量等信息"
	$(".header_search").on("click",".search_icon",function(){
		$(".all_header").css("display","block");
		$(".search_input").css("display","none");
        var ec_type = $('input[name="ec_type"]').val();
        if(ec_type == 'line'){//选择7日销量的时候 不显示时间选择界面
			$(".compass_time").css("display","none");
			$('#botFixedmoney').css("display","block");
        }else{
            $(".compass_time").css("display","block");
            $('#botFixedmoney').css("display","none");
        }
		$("#suggest_ul").css("display","none");
		$(".search_tu").css("display","none");
	})
	
	//点击时间
	$(".time_left").on("click",function(){
		var center = $(".time_center").attr("data_time");
        var ec_type = $('input[name="ec_type"]').val();
        var id = $('input[name="lid"]').val();
        var line_type = $('input[name="line_type"]').val();
		$.getJSON('t.php', {
				action:'left', 
				time_center:center	
			},function(data){
				var list = data.list;
				if(data.sta =='suc'){
					$(".time_left_num").text(list["time_left"]);
					$(".time_center").text(list["time_center"]);
					$(".time_center").attr("data_time",list["time_center"]);
					$(".time_right_num").text(list["time_right"]);
                    Ajax(ec_type,list["time_center"],line_type,'',id);
				}else{}
			}
        )
	})
	
	//点击时间
	$(".time_right").on("click",function(){
		var center = $(".time_center").attr("data_time");
        var ec_type = $('input[name="ec_type"]').val();
        var id = $('input[name="lid"]').val();
        var line_type = $('input[name="line_type"]').val();
		$.getJSON('t.php', {
				action:'right', 
				time_center:center	
			},function(data){
				var list = data.list;
				if(data.sta =='suc'){
					$(".time_left_num").text(list["time_left"]);
					$(".time_center").text(list["time_center"]);
					$(".time_center").attr("data_time",list["time_center"]);
					$(".time_right_num").text(list["time_right"]);
                    Ajax(ec_type,list["time_center"],line_type,'',id);
				}
				else{ 
				}
			}) 

	})

	//底部三个按钮的 点击  变换颜色的事件
	$("#botFixedBar").on('click','span',function(e){
		var target = $(e.currentTarget);
		var ec_type = target.attr('data-ec_type');
        var id = $('input[name="lid"]').val();
        var line_type = $('input[name="line_type"]').val();
		$('input[name="ec_type"]').val(ec_type);
        var btime3 = $(".time_center").attr("data_time");
        Ajax(ec_type,btime3,line_type,'',id);
		switch (ec_type){
				case 'line':
					$(this).addClass("active");
					$(".botFixedmoney").css("display","block");
					$(".compass_time").css("display","none");
					$(".channels").removeClass("active");
					$(".source").removeClass("active");
					break;
				case 'pie':
					$(this).addClass("active");
					$(".botFixedmoney").css("display","none");
					$(".compass_time").css("display","block");
					$(".sevenday").removeClass("active");
					$(".source").removeClass("active");
					break;
				default :
					$(".source").addClass("active");
					$(".botFixedmoney").css("display","none");
					$(".compass_time").css("display","block");
					$(".sevenday").removeClass("active");
					$(".channels").removeClass("active");
			}
		})
		
	$("#botFixedmoney").on('click','span',function(e){  //点击折线图 才出现的金额和票数
		var target = $(e.currentTarget);
        var btime3 = $(".time_center").attr("data_time");
		var line_type = target.attr('data-line_type');
        var id = $('input[name="lid"]').val();
		$('input[name="line_type"]').val(line_type);
        Ajax('line',btime3,line_type,'',id);
		switch (line_type){
				case 'tnum':
					$(this).addClass("active");
					$(".ticket_money").removeClass("active");
					break;
				default :
					$(this).addClass("active");
					$(".ticket_num").removeClass("active");
			}
		})
	$(".botFixedmoney").css("display","block");
	//$(".compass_time").css("display","none");

});

$(function(){
	$(".linebox").click(function(){
		$(".topbox,.nonehtml,.morebox,.selecton").css("display","none");
		$(".icon_search,.iconbox,.return_txt,.search_input,#suggest_ul").css("display","inline-block");
		$(this).css({"border":"0 none","padding":"5px 0 10px 0"}); 
	});
	$(".cleartxt").click(function(){
		$('.search_input').val('');
		$(this).css("display","none");
	}); 
	$(".return_txt").click(function(){
		$(".topbox,.nonehtml,.morebox,.selecton").css("display","block");
		$(".icon_search,.iconbox,.return_txt,.search_input,#suggest_ul").css("display","none");
		$(".linebox").css({"border-top":"1px solid #FFF","padding":"0"});
	});
	
	
	
		$("#suggest_ul").on("click","li",function(e){
			var target = $(e.currentTarget);
			var id = $('#lid_id').val();
            var line_type = $(".line_type").val();
            var dname = target.text();
			var length=dname.length;
			if(length>12){
				dname=dname.substr(0,12)+"...";
				$('.search_arem').text(dname);
				$(".search_arem").val(dname);
				
			}else{
				$('.search_arem').text(dname);
				$(".search_arem").val(dname);
			}
			$("#suggest_ul").hide(0);
			$(".all_header").css("display","block");
			$(".compass_time").css("display","block");
			var btime3 = $(".time_center").attr("data_time");
			var ec_type = $('input[name="ec_type"]').val();//设置一个隐藏的按钮 存当前是什么地图类型
            if(ec_type == 'line'){//选择7日销量的时候 不显示时间选择界面
                $(".compass_time").css("display","none");
                $('#botFixedmoney').css("display","block");
            }else{
                $(".compass_time").css("display","block");
                $('#botFixedmoney').css("display","none");
            }
            Ajax(ec_type,btime3,line_type,'',id);
		})
	
		
})


function list(){
	var list = lands.list;
	for(var i=0;i<list.length;i++){
	    $("#suggest_ul").append("<li>"+list[i].title+"</li>");
	}
	$("#suggest_ul li").click(function(){
		var i=$(this).index();
		$(".search_input,.selecton").val(list[i].title);
		$("#suggest_ul li").removeClass("setbg");
		$("#suggest_ul li").eq(i).addClass("setbg");
		$("#suggest_ul").css("display","none");
		$("#lid_id").val(list[i].id);
		$(".topbox,.nonehtml,.morebox,.selecton").css("display","block");
		$(".cleartxt").css("display","inline-block");
		$(".icon_search,.iconbox,.return_txt,.search_input,#suggest_ul").css("display","none");
		$(".linebox").css({"border-top":"1px solid #FFF","padding":"0"});
	});
};

$(function(){
    $('.search_input').bind('input propertychange', function() {
        var sth=$(this).val();
		$(".cleartxt").css("display","inline-block");
        var i=0;
        $("#suggest_ul li").each(function(){
            var n=$(this).text().indexOf(sth);
            if(n==-1){
                $(this).css("display","none");
            }else{
                i+=1
                $(this).css("display","block");
            }
        });

        if(i==0){
            $(".searchmsg").css("display","block");
            $("#suggest_ul").css("display","none");
        }else{
            $(".searchmsg").css("display","none");
            $("#suggest_ul").css("display","block");
        }
    })
    list();
});

    













